package com.onepice.mlp.utils.commom;


import com.alibaba.fastjson.JSONObject;
import com.onepice.mlp.utils.enums.CodeType;


/**
 * ResponseResult
 *
 * @author wangzhao
 * @version v1.0
 * @date 2021年6月21日
 */
public class ResponseResult {
    private static JSONObject result;

    public static JSONObject build(CodeType status, String message) {
        result = new JSONObject();
        switch (status) {
            case SUCCESS:
                result.put("resultCode", status.getName());
                result.put("resultMessage", message == null || message == "" ? "成功！" : message);
                break;
            case FAIL:
                result.put("resultCode", status.getName());
                result.put("resultMessage", message == null || message == "" ? "失败！" : message);
                break;
            case USER_NOT_LOGIN:
                result.put("resultCode", status.getName());
                result.put("resultMessage", "用户未登录！");
                break;
            case NO_PRIVILEGE:
                result.put("resultCode", status.getName());
                result.put("resultMessage", "没有权限！");
                break;
            default:
        }
        return result;
    }

}
